
import React, { useState } from 'react';
import { Form, Input, InputNumber } from 'antd';
import an58 from '@mmstudio/an000058';
import { Message as M1, Result as R1 } from '../api/classgroup/list/edit.api';
import EditButton from '../../components/editbutton';
import api from '../../atoms/api';



export default function Edit({ data }: {
	data: M1;

}) {
	const [d, setd] = useState(data);
	return <>
		<EditButton dlgtitle='专业管理' onSave={async () => {
			if (!d
				|| !d.groupintroduce
				|| !d.groupname
			) {
				return '缺少必要的参数';
			}
			const res = await an58<R1, M1>(api['/api/classgroup/list/edit'], 'post', d);
			if (res.ok === true) {
				return true;
			}
			return res.message;
		}}>
			<Form.Item required label="课组名称">
				<Input placeholder='请输入课组名称' value={d.groupname} onChange={(e) => {
					setd({
						...d,
						groupname: e.target.value
					});
				}} />
			</Form.Item>
			<Form.Item required label="课组简介">
				<textarea className='ta' placeholder='请输入课组简介' onChange={(e) => {
					setd({
						...d,
						groupintroduce: e.target.value
					});
				}} >{d.groupintroduce}</textarea>
			</Form.Item>
		</EditButton>
		<style jsx>{`
		.ta{
width:100%;
height:10rem;
}
.da{
width:100%;
height:10rem;
}
		`}</style>
	</>;
}
